package com.tjbank.cssys.mybatis.impl;

import com.tjbank.cssys.mybatis.IamMenuDao;
import com.tjbank.cssys.mybatis.entity.IamMenu;
import com.tjbank.cssys.mybatis.entity.IamMenuKey;
import com.tjbank.cssys.mybatis.mapper.IamMenuMapper;
import com.tjbank.cssys.mybatis.sqlbuilder.IamMenuSqlBuilder;
import java.util.List;
import javax.annotation.Resource;

import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * IamMenuDaoImpl
 * 
 * @author PG(Auto Generator)
 * @version V2.0
 */
@Service
public class IamMenuDaoImpl implements IamMenuDao {
    @Resource
    private IamMenuMapper iamMenuMapper;

    public IamMenuDaoImpl() {
        super();
    }

    @Override
    public List<IamMenu> selectListBySqlBuilderWithBLOBs(IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        return iamMenuMapper.selectBySqlBuilderWithBLOBs(iamMenuSqlBuilder);
    }

    @Override
    public List<IamMenu> selectListBySqlBuilder(IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        return iamMenuMapper.selectBySqlBuilder(iamMenuSqlBuilder);
    }

    @Override
    public IamMenu selectBySqlBuilderWithBLOBs(IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        List<IamMenu> listIamMenus = selectListBySqlBuilderWithBLOBs(iamMenuSqlBuilder);
        if (listIamMenus == null || listIamMenus.isEmpty()) {
            return null;
        } else if (listIamMenus.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamMenus.get(0);
    }

    @Override
    public IamMenu selectBySqlBuilder(IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        List<IamMenu> listIamMenus = selectListBySqlBuilder(iamMenuSqlBuilder);
        if (listIamMenus == null || listIamMenus.isEmpty()) {
            return null;
        } else if (listIamMenus.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamMenus.get(0);
    }

    @Override
    public IamMenu selectByPrimaryKey(IamMenuKey iamMenuKey) throws RuntimeException {
        return iamMenuMapper.selectByPrimaryKey(iamMenuKey);
    }

    @Override
    public long countBySqlBuilder(IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        return iamMenuMapper.countBySqlBuilder(iamMenuSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insert(IamMenu iamMenu) throws RuntimeException {
        return iamMenuMapper.insert(iamMenu);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insertUseBatch(List<IamMenu> listIamMenus) throws RuntimeException {
        return iamMenuMapper.insertUseBatch(listIamMenus);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilder(IamMenu iamMenu, IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        iamMenuSqlBuilder.setUpdateObject(iamMenu);
        return iamMenuMapper.updateBySqlBuilder(iamMenuSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilderSelective(IamMenu iamMenu, IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        iamMenuSqlBuilder.setUpdateObject(iamMenu);
        return iamMenuMapper.updateBySqlBuilderSelective(iamMenuSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKey(IamMenu iamMenu) throws RuntimeException {
        return iamMenuMapper.updateByPrimaryKey(iamMenu);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKeySelective(IamMenu iamMenu) throws RuntimeException {
        return iamMenuMapper.updateByPrimaryKeySelective(iamMenu);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteBySqlBuilder(IamMenuSqlBuilder iamMenuSqlBuilder) throws RuntimeException {
        return iamMenuMapper.deleteBySqlBuilder(iamMenuSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteByPrimaryKey(IamMenuKey iamMenuKey) throws RuntimeException {
        return iamMenuMapper.deleteByPrimaryKey(iamMenuKey);
    }
}